package com.lw.test.entity;

import java.util.Objects;
import javax.persistence.Entity;
import javax.persistence.Id;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/** @author YiFeiXi */
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserInfo {
  @Id private Integer id;
  private String firstName;
  private String lastName;

  @Override
  public int hashCode() {
    return firstName.hashCode() + lastName.hashCode();
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }
    if (obj instanceof UserInfo) {
      UserInfo otherUser = (UserInfo) obj;
      return Objects.equals(this.id, otherUser.id)
          && Objects.equals(this.firstName, otherUser.firstName)
          && Objects.equals(this.lastName, otherUser.lastName);
    }
    return false;
  }
}
